<template>

  <div style="height: 100%;">
    <el-container>
      <el-aside width="200px" style="background-color: white;">
        <el-tree :load="loadNode" :props="defaultProps" lazy @node-click="handleNodeClick" :highlight-current="true"
          ></el-tree>
      </el-aside>
      <el-main>
        <manage ref="mainView" @sub="onManageSub"></manage>
      </el-main>
    </el-container>
  </div>
  
</template>

<script setup>

import manage from './manage'

import { getTreeNodesByParentId } from "./api.js";

const defaultProps = ref({
  children: "children",
  label: "name"
});

const mainView = ref();

/** 查询资产分类表列表 */
function loadNode(node, resolve) {
  const data = node.data;
  let parentId = 0;
  if (data) {
    parentId = data.id;
  }

  getTreeNodesByParentId(parentId).then(response => {
    resolve(response);
  });
}

function handleNodeClick(data) {
  mainView.value.changeParent(data);
}

function onManageSub() {

}


</script>
